public class SeqQueue<T> : IQueue<T>
{
    public int MaxSize { get; set; }//容量
    public T[] Data { get; set; }
    public int Front { get; set; }//队头指针
    public int Rear { get; set; }//队尾指针
    /// <summary>
    /// 索引器
    /// </summary>
    /// <value></value>
    public T this[int index]
    {
        get
        {
            return Data[index];
        }
        set
        {
            Data[index] = value;
        }
    }
    public SeqQueue(int maxSize)
    {
        Data = new T[maxSize];
        MaxSize = maxSize;
        Front = Rear = -1;//这里用-1
    }
    public void Clear() => Front = Rear = -1;

    public T GetFront()
    {
        if(IsEmpty())
        {
            System.Console.WriteLine("队空");
            return default(T);
        }
        return Data[Front+1];
    }

    public int GetLength() => (Rear - Front + MaxSize) % MaxSize;

    public void In(T item)
    {
        if (IsFull())
        {
            System.Console.WriteLine("队满");
            return;
        }
        //Data[++Rear] = item;  //顺序不循环
        Data[++Rear%MaxSize] = item; //循环队列
    }

    public bool IsEmpty() => Front == Rear;
    public bool IsFull() => (Rear + 1) % MaxSize == Front;

    public T Out()
    {
        if(IsEmpty())
        {
            System.Console.WriteLine("队空");
            return default(T);
        }
        //Data[++Rear] = item;  //顺序不循环
        return Data[++Front%MaxSize];
    }
}